package com.forekenow.work0723.play;

import java.util.Random;
import java.util.Scanner;

public class Game {

    Computer computer = new Computer();
    User user = new User();

    public void initial(){
        System.out.println("------欢迎进入游戏世界------");
        Computer computer = new Computer();
        System.out.println("----猜拳，开始----");
        System.out.println("出拳规则：1.剪刀 2.石头 3.布");
        Scanner scanner = new Scanner(System.in);
        System.out.println("请选择对方角色（1：刘备  2：孙权  3：曹操）：");
        int num = scanner.nextInt();
        choosehero(num,computer);
        switch (num){
            case 1:
                System.out.println("您选择了刘备对战");
                break;
            case 2:
                System.out.println("您选择了孙权对战");
                break;
            case 3:
                System.out.println("您选择了曹操对战");
                break;
            default:
                System.out.println("您选的英雄还么有出生");
        }
        startGame(user,computer);
    }
    public void choosehero(int num,Computer computer){
        switch (num){
            case 1:
                computer.setName("刘备");
                break;
            case 2:
                computer.setName("孙权");
                break;
            case 3:
                computer.setName("曹操");
                break;
            default:
                computer.setName("匿名");
                break;

        }
    }

    public void startGame(User user,Computer computer){
        System.out.println(user.getName()+"VS"+computer.getName());
    }

    public void  ask(Computer computer){
        System.out.println("要开始吗(输入Y或者y)");
        Scanner scanner = new Scanner(System.in);
        String next = scanner.next();
        while (next.equals("Y")||next.equals("y")){
            System.out.println("请出拳：1.剪刀 2.石头 3.布");
            int b = scanner.nextInt();
            if (b==1){
                user.setQuan("剪刀") ;
                System.out.println("您出的是剪刀");
            }else if (b==2){
                user.setQuan("石头");
                System.out.println("您出的是石头");
            }else {
                user.setQuan("布");
                System.out.println("您出的是布");
            }
            Random random1 = new Random();
            int a = random1.nextInt(3);
            if (a==1){
                computer.setQuan("剪刀") ;
                System.out.println(computer.getName()+"出的是剪刀");
            }else if (a==2){
                computer.setQuan("石头");
                System.out.println(computer.getName()+"出的是石头");
            }else {
                computer.setQuan("布");
                System.out.println(computer.getName()+"出的是布");
            }
        }

    }
    public void showFirst(){

    }

    public static void main(String[] args) {
        Game game =new Game();
        User user = new User();
        Computer computer = new Computer();
        game.initial();
        game.ask(computer);
    }
}
